﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Daycare.Models;
using Daycare.DAL;

namespace Daycare.Services
{
    public class ConfigurationSettingsService
    {
        ConfigurationSettingsRepository csr;

        public List<ConfigurationSetting> GetConfigurationSettings(int configurationGroupId = 0)
        {
            csr = new ConfigurationSettingsRepository();

            return csr.GetConfigurationSettings(configurationGroupId);
        }

        public ConfigurationSetting GetConfigurationSetting(int configurationSettingsId)
        {
            csr = new ConfigurationSettingsRepository();

            List<ConfigurationSetting> configs = csr.GetConfigurationSettings();
            ConfigurationSetting config = null;

            foreach(ConfigurationSetting sett in configs)
            {
                if(sett.configurationSettingsId == configurationSettingsId)
                {
                    config = sett;
                    break;
                }
            }

            return config;
        }

        public ConfigurationSetting GetConfigurationSetting(String configSettingName)
        {
            csr = new ConfigurationSettingsRepository();

            List<ConfigurationSetting> configs = csr.GetConfigurationSettings();
            ConfigurationSetting config = null;

            foreach (ConfigurationSetting sett in configs)
            {
                if (sett.configurationSettingsName == configSettingName)
                {
                    config = sett;
                    break;
                }
            }

            return config;
        }
    }
}